package com.rrqs.activity;

import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.TextView;

import com.zadtek.xmqishi.R;

/**
 * 骑手信息
 * @author Administrator
 *
 */
public class UpdateActivity extends Activity {
	private ImageView backid;
	private TextView topview;
	private WebView webView;
	String titleurl="";
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.managementrules);

		titleurl=getIntent().getStringExtra("url");
		
		backid = (ImageView) findViewById(R.id.backid);
		topview = (TextView) findViewById(R.id.topview);
		topview.setText("版本更新");

		webView =(WebView) findViewById(R.id.management);
		WebSettings webSettings = webView.getSettings();
		webSettings.setJavaScriptEnabled(true);
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
			webView.setWebContentsDebuggingEnabled(true);
		}
		webView.getSettings().setJavaScriptEnabled(true);
		webView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
		webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);  //设置 缓存模式
		// 开启 DOM storage API 功能
		webView.getSettings().setDomStorageEnabled(false);
		//开启 database storage API 功能
		webView.getSettings().setDatabaseEnabled(true);
		final String cacheDirPath = getFilesDir().getAbsolutePath();
//      String cacheDirPath = getCacheDir().getAbsolutePath()+Constant.APP_DB_DIRNAME;
		//设置数据库缓存路径
//        mWebView.getSettings().setDatabasePath(cacheDirPath);
		//设置  Application Caches 缓存目录
		webView.getSettings().setAppCachePath(cacheDirPath);
		//开启 Application Caches 功能
		webView.getSettings().setAppCacheEnabled(true);
		webView.getSettings().setAllowFileAccess(true);
		webView .getSettings().setMediaPlaybackRequiresUserGesture(false);
		backid.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				UpdateActivity.this.finish();
			}
		});
		webView.loadUrl(titleurl);
		// 覆盖WebView默认使用第三方或系统默认浏览器打开网页的行为，使网页用WebView打开
		webView.setWebViewClient(new WebViewClient() {
			@Override
			public boolean shouldOverrideUrlLoading(WebView view, String url) {
				// TODO Auto-generated method stub
				// 返回值是true的时候控制去WebView打开，为false调用系统浏览器或第三方浏览器
				view.loadUrl(url);
				return true;
			}
		});
	}
}
